<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>侧边导航栏</title>
    <link rel="stylesheet" href="css/font-awesome.css">
    <link rel="stylesheet" href="css/bootstrap.css">
    <!-- <link rel="stylesheet" href="css/style.css"> -->
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        a {
            text-decoration: none
        }

        html,
        body {
            height: 100%;
        }

        body {
            /* background: url('../images/1.png') 50% / cover no-repeat; */
        }

        .menu-wrap {
            position: fixed;
            left: 0;
            top: 0;
            bottom: 0;
            width: 55px;
            background-color: #f5f5f5;
            box-shadow: 1px 0 15px rgba(0, 0, 0, 0.07);
            overflow: hidden;
        }

        .menu-wrap:hover {
            width: 250px;
        }

        .menu {
            position: absolute;
            left: 0;
            top: 80px;
            bottom: 80px;
            width: 250px;
            overflow-y: auto;
            margin-top: 80px;
        }

        .menu li {
            height: 42px;
            line-height: 42px;

        }

        .menu li:hover {
            background-color: rgb(160, 190, 117);
        }

        .menu li:hover a {
            color: #fff;
        }

        .menu a {
            display: block;
            columns: #8a8a8a;
            border-top: 1px solid #e9e9e9;
        }

        .menu i {
            display: inline-block;
            width: 55px;
            text-align: center;
            font-size: 18px;
        }

        .menu span {
            font-size: 14px;
        }

        /* 侧边头像 */
        #headPic{
            width: 80px;
            height: 80px;
            border:1px solid #ccc;
            border-radius: 75px;
            margin-left:80px;
            /* margin:20px auto; */
            position:relative;
            overflow: hidden;
            top:50px;
        }
        #headPicimg{
            width: 80px;
            height: 80px;
        }
        #headPic:hover #mask{
            display:block;
        }
        #mask{
            width: 150px;
            height: 150px;
            background-color: rgba(0,0,0,0.5);
            position:absolute;
            left:0;
            top:0;
            display:none;
        }
        #innerImg{
            position: absolute;
            left:25%;
            top:25%;
            transform: translate(-50%,-50%);    /*适用于不清楚自己的尺寸情况*/
        }
    </style>
    <script>
        window.onload = function(){
            document.querySelector('#headPic').onclick = function(){
                document.querySelector('#headPic input').click()     //模拟表单元素被单击
            }
        }
        function changeHeadPic(){
            //1.获取图片文件
            var fileHead = document.querySelector('#headPic input').files[0]
            //2.文件读取图片
            var fread = new FileReader()
            fread.onload = function(e){
                //3.把图片显示在页面中
                document.querySelector('#headPic>img').src = e.target.result
            }
            fread.readAsDataURL(fileHead)
        }
    </script>

</head>

<body>
    <nav class="menu-wrap">
        <div id="headPic">
            <img id="headPicimg" src="images/icon_shangjie.gif" alt="">
            <div id="mask">
                <img id="innerImg" src="" 
                alt="">            
            </div>
            <form action="http://localhost:3000/users/uploadHeadPic" method="POST" enctype="multipart/form-data">
                <input type="file" name="" id="" accept="image/jpg" onchange="changeHeadPic()" style="display:none">
            </form>
        </div>


        <div class="menu">
            <ul>

                <li>
                    <a href="shouye.html">
                        <i class="fa fa-home fa-lg"></i>
                        <span class="nav-text">首页</span>
                    </a>
                </li>
                <li>
                    <a href="edit.html">
                        <i class="fa fa-bullhorn fa-lg"></i>
                        <span class="nav-text">编辑资料</span>
                    </a>
                </li>
                <li>
                    <a href="sharemenu.html">
                        <i class="fa fa-user fa-lg"></i>
                        <span class="nav-text">上传菜谱</span>
                    </a>
                </li>
                <li>
                    <a href="personal.html">
                        <i class="fa fa-envelope-o fa-lg"></i>
                        <span class="nav-text">已发布的内容</span>
                    </a>
                </li>
                <li>
                    <a href="shoucang.html">
                        <i class="fa fa-heart-o fa-lg"></i>
                        <span class="nav-text">收藏</span>
                    </a>
                </li>
                <li>
                    <a href="integral.html">
                        <i class="fa fa-shopping-bag fa-lg"></i>
                        <span class="nav-text">积分兑换</span>
                    </a>
                </li>
            </ul>
        </div>
    </nav>
</body>

</html>